load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "tsearch",
    srcs = [
        "config.go",
        "encoding.go",
        "eval.go",
        "lex.go",
        "random.go",
        "rank.go",
        "snowball.go",
        "stopwords.go",
        "tsquery.go",
        "tsvector.go",
    ],
    embedsrcs = [
        "stopwords/chinese.stop",
        "stopwords/danish.stop",
        "stopwords/dutch.stop",
        "stopwords/english.stop",
        "stopwords/finnish.stop",
        "stopwords/french.stop",
        "stopwords/german.stop",
        "stopwords/hungarian.stop",
        "stopwords/italian.stop",
        "stopwords/nepali.stop",
        "stopwords/norwegian.stop",
        "stopwords/portuguese.stop",
        "stopwords/russian.stop",
        "stopwords/spanish.stop",
        "stopwords/swedish.stop",
        "stopwords/turkish.stop",
    ],
    importpath = "github.com/cockroachdb/cockroach/pkg/util/tsearch",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/keysbase",
        "//pkg/sql/inverted",
        "//pkg/sql/pgwire/pgcode",
        "//pkg/sql/pgwire/pgerror",
        "//pkg/util/encoding",
        "@com_github_blevesearch_snowballstem//:snowballstem",
        "@com_github_blevesearch_snowballstem//danish",
        "@com_github_blevesearch_snowballstem//dutch",
        "@com_github_blevesearch_snowballstem//english",
        "@com_github_blevesearch_snowballstem//finnish",
        "@com_github_blevesearch_snowballstem//french",
        "@com_github_blevesearch_snowballstem//german",
        "@com_github_blevesearch_snowballstem//hungarian",
        "@com_github_blevesearch_snowballstem//italian",
        "@com_github_blevesearch_snowballstem//norwegian",
        "@com_github_blevesearch_snowballstem//portuguese",
        "@com_github_blevesearch_snowballstem//russian",
        "@com_github_blevesearch_snowballstem//spanish",
        "@com_github_blevesearch_snowballstem//swedish",
        "@com_github_blevesearch_snowballstem//turkish",
        "@com_github_cockroachdb_errors//:errors",
    ],
)

go_test(
    name = "tsearch_test",
    srcs = [
        "encoding_test.go",
        "eval_test.go",
        "rank_test.go",
        "tsquery_test.go",
        "tsvector_test.go",
    ],
    embed = [":tsearch"],
    deps = [
        "//pkg/sql/inverted",
        "//pkg/testutils/skip",
        "//pkg/util/randutil",
        "@com_github_jackc_pgx_v4//:pgx",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
    ],
)
